package com.widevision.adapter;

import java.util.ArrayList;

import com.androidquery.AQuery;

import net.widevision.android.R;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class FollowerListAdapter  extends BaseAdapter{
	
	
	ArrayList<Object> itemList;
 
    public Activity context;
    public LayoutInflater inflater;
  //***********************************//
    private AQuery mainAQuery;
    //***********************************//
    public FollowerListAdapter(Activity context,ArrayList<Object> itemList,AQuery aq) {
        super();
 
        this.context = context;
        this.itemList = itemList;
        
        this.inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        //***********************************//
        mainAQuery = aq;
    }
 
    
    public int getCount() {
        // TODO Auto-generated method stub
        return itemList.size();
    }
 
    
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return itemList.get(position);
    }
 
  
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return 0;
    }
 
    public static class ViewHolder
    {
        TextView name;
        ImageView image;
        TextView userId;
       
    }
 
 
    public View getView(int position, View convertView, ViewGroup parent) 
    {
        final ViewHolder holder;
        if(convertView==null)
        {
            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.followerlistitem, null);
            holder.image = (ImageView) convertView.findViewById(R.id.frndimg);
            holder.name = (TextView) convertView.findViewById(R.id.frndname);
            holder.userId=(TextView) convertView.findViewById(R.id.userId);
            convertView.setTag(holder);
            
        }
        else
        	
        holder=(ViewHolder)convertView.getTag();
 
        FollowerListBean bean = (FollowerListBean) itemList.get(position);
        //***********************************//
        AQuery aq = mainAQuery.recycle(convertView);
        //***********************************//
        holder.name.setText(bean.getName());
//        holder.image.setBackgroundDrawable(bean.getImage());
        aq.id(R.id.frndimg).image(bean.getImage(), true, true, 0, 0, null, AQuery.FADE_IN, AQuery.RATIO_PRESERVE);
        holder.userId.setText(bean.getUserId());

        return convertView;
    }
 
}

